namespace mecs {
    export class RandomSeed {
        protected m_seed: number;
        protected m_cnt: number;

        constructor(seed: number) {
            this.m_cnt = 0;
            this.reset(seed);
        }
        get crtSeedNum() {
            return this.m_seed;
        }
        get seedCnt() {
            return this.m_cnt;
        }
        /** 重置随机种子 */
        reset(seed: number) {
            this.m_seed = seed || Date.now();
        }
        /** 随机出原始数据 */
        random(max = 1, min = 0) {
            if (max < min) {
                console.log("随机数max不能小于min");
                return 0;
            }
            this.m_seed = (this.m_seed * 9301 + 49297) % 233280;
            var rnd = this.m_seed / 233280.0;
            this.m_cnt++;
            return min + rnd * (max - min);
        }

        /** 向上取整int数据 (min,max] */
        randomCeil(max = 1, min = 0) {
            return Math.ceil(this.random(max, min));
        }
        /** 四舍五入int数据 [min,max] */
        randomInt(max = 1, min = 0) {
            return Math.round(this.random(max, min));
        }
        /** 向下取整int数据 [min,max) */
        randomFloor(max = 1, min = 0) {
            return Math.floor(this.random(max, min));
        }
    }
}